<?php
session_start();
include_once './funcoes.php';
$cargos = getCargo($_SESSION['idEmpresa']);
$numCargos = mysql_num_rows($cargos);
?>
<!doctype html>
<html lang="pt-br">
    <head>
        <meta charset="UTF-8">
        <title>Cadastro de Funcionario</title>
        <link href="bootstrap/css/bootstrap.css" rel="stylesheet" media="screen">
        <link rel="stylesheet" type="text/css" href="estilo.css">
        <script src="js/jquery-1.2.6.pack.js" type="text/javascript"></script>
        <script src="js/jquery.maskedinput-1.1.4.pack.js" type="text/javascript" ></script>
        <script type="text/javascript">
            $(document).ready(function(){	
            $("#cpf").mask("999.999.999-99");
            $("#telefone").mask("(99)9999-9999");
            $("#nome").focus();
            
            $("#submit").click(function(){
                
		var senha		=	$("#senha1").val();
		var senha2		=	$("#senha2").val();
		
		if (senha != senha2){
			alert("As senhas não conferem!");
			$("#senha1").focus();
			return false;
		}
		else{
		var confirma	=	confirm("Deseja realmente realizar esta ação?");
		if (confirma == true){
		return true;
		}
		else{
			return false;
		}
		}
	});
            
            });
        </script>
    </head>
    <body>
        <script src="js/bootstrap.js"></script>
        
            <div class = "container">
                <form action="modelo/modeloFuncionario" method="POST">
            <input type="hidden" value="inserir" name="operacao" />
                <div class="row-fluid ">
                    <div class="span12-fluid  offset2">
                        <ul class="nav nav-pills nav-justified">
                            <li class="active">
                                <a >Cadastro de Funcionário </a>
                            </li>
                            <li >
                                <a href="/" >Voltar</a>
                            </li>
                        </ul> 
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="form-horizontal">
                        <div class="col-xs-3 offset2">
                            <div class="control-group">
                                <label class="col-sm-0 control-label" for="selectbasic">Cargo</label>
                                <div class="controls-lg selectpicker">
                                    <select id="selectbasic" class="form-control" name="id_cargo" required="required">
                                        <option value="">Selecione</option>
                                        <?php
                                        for ($i = 0; $i < $numCargos; $i++) {
                                            mysql_data_seek($arrayCargos, $i);
                                            $arrayCargos = mysql_fetch_array($cargos);
                                            echo '<option value="' . $arrayCargos['id_cargo'] . '">' . $arrayCargos['nome_cargo'] . '</option>';
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row-fluid">

                            <div class="form-horizontal">
                                <div class="col-xs-3 offset2">
                                    <div class="control-group">
                                        <label class="col-sm-0 control-label" for="selectbasic">Empresa</label>
                                        <div class="controls-lg selectpicker" placeholder="Nome">
                                            <?php
                                            $empresa = mysql_fetch_array(getEmpresa($_SESSION['idEmpresa']));
                                            echo '<input class="form-control" type="text" value="' . $empresa['nomefantasia'] . '" disabled="disabled" />';
                                            ?>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-12 offset2">
                                    <label class="col-sm-0 control-label">Nome </label>
                                    <input id="nome" type="text" class="form-control" name="nome" placeholder="Nome">
                                </div>

                                <div class="col-xs-12 offset2">
                                    <label class="col-sm-0 control-label">Apelido</label>
                                    <input type="text" class="form-control" name="apelido" placeholder="Apelido">
                                </div>

                                <div class="col-xs-6 offset2">
                                    <label class="col-sm-0 control-label">CPF</label>
                                    <input type="text" class="form-control" name="cpf" placeholder="CPF" id="cpf">
                                </div>


                                <div class="col-xs-6 offset2">
                                    <label class="col-sm-0 control-label">Identidade</label>
                                    <input type="text" class="form-control" name="rg" placeholder="RG">
                                </div>

                                <div class="col-xs-3 offset2">
                                    <label class="col-sm-0 control-label">Endereço</label>
                                    <input type="text" class="form-control" name="endereco_usuario" placeholder="Endereço">
                                </div>

                                <div class="col-xs-3 offset2">
                                    <label class="col-sm-0 control-label">Número</label>
                                    <input type="text" class="form-control" name="numero_usuario" placeholder="Número">
                                </div>


                                <div class="col-xs-3 offset2">
                                    <label class="col-sm-0 control-label">Bairro</label>
                                    <input type="text" class="form-control" name="bairro_usuario" placeholder="Bairro">
                                </div>

                                <div class="row-fluid">

                                    <div class="form-horizontal">
                                        <div class="col-xs-3 offset2">
                                            <div class="control-group">
                                                <label class="col-sm-0 control-label" for="selectbasic">Cidade</label>
                                                <div class="controls-lg selectpicker">
                                                    <select id="selectbasic" class="form-control" name="genero" required="required">
                                                        <option value="">Selecione</option>
                                                        <?php
                                                        $cidades = getCidade();
                                                        $numCidades = mysql_num_rows($cidades);

                                                        for ($i = 0; $i < $numCidades; $i++) {
                                                            mysql_data_seek($arrayCidades, $i);
                                                            $arrayCidades = mysql_fetch_array($cidades);
                                                            echo '<option value="' . $arrayCidades['id_cidade'] . '">' . $arrayCidades['nome_cidade'] . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>


                                        <div class="col-xs-3 offset2">
                                            <label class="col-sm-0 control-label">Telefone</label>
                                            <input type="text" class="form-control" name="telefone_usuario" placeholder="Telefone" id="telefone">
                                        </div>


                                        <div class="col-xs-9 offset2">
                                            <label class="col-sm-0 control-label">Email</label>
                                            <input type="text" class="form-control" name="email_usuario" placeholder="Email">
                                        </div>
                                        <div class="row-fluid">

                                            <div class="form-horizontal">
                                                <div class="col-xs-3 offset2">
                                                    <label class="col-sm-0 control-label">Login do Funcionário</label>
                                                    <input type="text" class="form-control" name="nome_usuario" placeholder="Login Do Usuário" required="required">
                                                </div>

                                                <div class="col-xs-3 offset2">
                                                    <label class="col-sm-0 control-label">Senha do Funcionário </label>
                                                    <input type="password" class="form-control" name="senha_usuario" placeholder="Senha do Usuário" id="senha1" required="required">
                                                </div>
                                                <div class="col-xs-3 offset2">
                                                    <label class="col-sm-0 control-label">Repita a Senha </label>
                                                    <input type="password" class="form-control" name="senha_usuario" placeholder="Senha do Usuário" id="senha2" required="required" >
                                                </div>


                                                <div class="col-xs-12 offset2">
                                                    <div class="btn-toolbar col-sm-0 control-label">

                                                        <input id="submit" type="submit" class="btn-lg glyphicon glyphicon-search" value="Salvar" />

                                                    </div>	
                                                </div>	
                                            </div>             
                                        </div>  	 		  
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
            </div>
                                    </body>
                                    </html>
